package com.bml.www.teacher.teacher;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bml.www.teacher.R;
import com.bml.www.teacher.account.utils.FragmentUtils;
import com.pachong.android.baseuicomponent.fragment.BaseFragment;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * A simple {@link Fragment} subclass.
 */
public class CourseFragment extends BaseFragment {


    @Bind(R.id.tv_course)
    TextView mTvCourse;
    @Bind(R.id.tv_table)
    TextView mTvTable;

    public CourseFragment() {
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view =super.onCreateView(inflater,container,savedInstanceState);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public View createDataView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_course, null);
        FragmentUtils.replaceFragment(getFragmentManager(),R.id.courseContent,new AllCourseFragment());
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick({R.id.tv_course, R.id.tv_table})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_course:
                mTvCourse.setBackground(getResources().getDrawable(R.drawable.top_selected_course));
                mTvTable.setBackground(getResources().getDrawable(R.drawable.top_right_course));
                FragmentUtils.replaceFragment(getFragmentManager(),R.id.courseContent,new AllCourseFragment());
                break;
            case R.id.tv_table:
                mTvCourse.setBackground(getResources().getDrawable(R.drawable.top_course));
                mTvTable.setBackground(getResources().getDrawable(R.drawable.top_right_selected_course));
                FragmentUtils.replaceFragment(getFragmentManager(),R.id.courseContent,new MonthCourseFragment());
                break;
        }
    }
}
